﻿/*
 @    Author : Rich of BeastModeMS
 @
 @    NPC = Mr. Oh
 @    Map =  MAP
 @    NPC MapId = MAPID
 @    Function = All in one Shop
 @
 */

var status = 0;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            cm.sendSimple("#e[百貨公司]#b歡迎購買!" +
                    "#k\r\n#L100##r劍士店#i1432038##L200##r法師店#i1052076##L300##r弓箭手店#i1452044##L400##r盜賊店#i1332050##L500##r海盜店#i1482023#\r\n#L600##r其他職業店\r\n#L700##r卷軸商店\r\n#L900##g椅子(500w)\r\n#L800##g坐騎");//\r\n#L900##g貢獻商店
        } else if (status == 1) {
            if (selection == 100) {
                cm.sendSimple("劍士店 #e#d" +
                        "#k\r\n#L0##r頭部" +
                        "#k#L1##r上衣" +
                        "#k#L2##r褲子" +
                        "#k#L3##r套服" +
                        "#k\r\n#L4##r手套" +
                        "#k#L5##r盾牌" +
                        "#k#L6##r鞋子" +
                        "#k\r\n#L7##r單手斧" +
                        "#k#L8##r雙手斧" +
                        "#k\r\n#L9##r單手棍" +
                        "#k#L10##r雙手棍" +
                        "#k\r\n#L11##r單手劍" +
                        "#k#L12##r雙手劍" +
                        "#k\r\n#L14##r矛" +
                        "#k#L13##r槍");
            } else if (selection == 200) {
                cm.sendSimple("法師店 #e#d" +
                        "#k\r\n#L15##b頭部" +
                        "#k#L16##b套服" +
                        "#k\r\n#L17##b手套" +
                        "#k#L19##b鞋子" +
                        "#k\r\n#L18##b盾牌" +
                        "#l\r\n#L20##b短杖" +
                        "#l#L21##b長杖");
            } else if (selection == 300) {
                cm.sendSimple("弓箭手店 #e#d" +
                        "#k\r\n#L22##d頭部" +
                        "#k#L23##d套服" +
                        "#k\r\n#L24##d手套" +
                        "#k#L25##d鞋子" +
                        "#k\r\n#L26##d弓" +
                        "#k#L27##d孥" +
                        "#k\r\n#L28##d箭");
            } else if (selection == 400) {
                cm.sendSimple("盜賊店 #e#d" +
                        "#k\r\n#L29##g頭部" +
                        "#k#L30##g上衣" +
                        "#k#L31##g褲子" +
                        "#k#L32##g套服" +
                        "#k\r\n#L33##g手套" +
                        "#k#L35##g鞋子" +
                        "#k\r\n#L34##g盾牌" +
                        "#k#L36##g短刀" +
                        "#k\r\n#L37##g拳套" +
                        "#k#L38##g飛鏢");
            } else if (selection == 500) {
                cm.sendSimple("海盜店 #e#d" +
                        "#k\r\n#L39##b頭部" +
                        "#k#L40##b套服" +
                        "#k\r\n#L41##b手套" +
                        "#k#L42##b鞋子" +
                        "#k\r\n#L43##b武器" +
                        "#k#L44##b子彈");
            } else if (selection == 600) {
                cm.sendSimple("其他職業店 #e#d" +
                        "#k\r\n#L45##b幻影佩特" +
                        "#k\r\n#L46##b卡牌" +
                        "#k\r\n#L47##b砲擊手" +
                        "#k\r\n#L48##b精靈雙奴" +
                        "#k\r\n#L49##b魔法箭" +
                        "#k\r\n#L50##b影武者" +
                        "#k\r\n#L52##b傑特武器" +
                        "#k\r\n#L53##b惡魔殺手"
                        );
            } else if (selection == 700) {
                cm.openShop(5000);
                cm.dispose();
            } else if (selection == 800) {
                cm.openShop(5006);
                cm.dispose();
            } else if (selection == 900) {
                cm.openShop(5004);
                cm.dispose();
            } else if (selection == 1000) {
                cm.openShop(5006);
                cm.dispose();
            }
        } else if (status == 2) {
            if (selection == 0) {
                cm.openShop(6100);
                cm.dispose();
            } else if (selection == 1) {
                cm.openShop(6101);
                cm.dispose();
            } else if (selection == 2) {
                cm.openShop(6102);
                cm.dispose();
            } else if (selection == 3) {
                cm.openShop(6103);
                cm.dispose();
            } else if (selection == 4) {
                cm.openShop(6104);
                cm.dispose();
            } else if (selection == 5) {
                cm.openShop(6105);
                cm.dispose();
            } else if (selection == 6) {
                cm.openShop(6106);
                cm.dispose();
            } else if (selection == 7) {
                cm.openShop(6107);
                cm.dispose();
            } else if (selection == 8) {
                cm.openShop(6108);
                cm.dispose();
            } else if (selection == 9) {
                cm.openShop(6109);
                cm.dispose();
            } else if (selection == 10) {
                cm.openShop(6110);
                cm.dispose();
            } else if (selection == 11) {
                cm.openShop(6111);
                cm.dispose();
            } else if (selection == 12) {
                cm.openShop(6112);
                cm.dispose();
            } else if (selection == 13) {
                cm.openShop(6113);
                cm.dispose();
            } else if (selection == 14) {
                cm.openShop(6114);
                cm.dispose();
            } else if (selection == 15) {
                cm.openShop(6200);
                cm.dispose();
            } else if (selection == 16) {
                cm.openShop(6201);
                cm.dispose();
            } else if (selection == 17) {
                cm.openShop(6202);
                cm.dispose();
            } else if (selection == 18) {
                cm.openShop(6203);
                cm.dispose();
            } else if (selection == 19) {
                cm.openShop(6204);
                cm.dispose();
            } else if (selection == 20) {
                cm.openShop(6205);
                cm.dispose();
            } else if (selection == 21) {
                cm.openShop(6206);
                cm.dispose();
            } else if (selection == 22) {
                cm.openShop(6300);
                cm.dispose();
            } else if (selection == 23) {
                cm.openShop(6301);
                cm.dispose();
            } else if (selection == 24) {
                cm.openShop(6302);
                cm.dispose();
            } else if (selection == 25) {
                cm.openShop(6303);
                cm.dispose();
            } else if (selection == 26) {
                cm.openShop(6304);
                cm.dispose();
            } else if (selection == 27) {
                cm.openShop(6305);
                cm.dispose();
            } else if (selection == 28) {
                cm.openShop(6306);
                cm.dispose();
            } else if (selection == 29) {
                cm.openShop(6400);
                cm.dispose();
            } else if (selection == 30) {
                cm.openShop(6401);
                cm.dispose();
            } else if (selection == 31) {
                cm.openShop(6402);
                cm.dispose();
            } else if (selection == 32) {
                cm.openShop(6403);
                cm.dispose();
            } else if (selection == 33) {
                cm.openShop(6404);
                cm.dispose();
            } else if (selection == 34) {
                cm.openShop(6405);
                cm.dispose();
            } else if (selection == 35) {
                cm.openShop(6406);
                cm.dispose();
            } else if (selection == 36) {
                cm.openShop(6407);
                cm.dispose();
            } else if (selection == 37) {
                
                cm.dispose();
                cm.openShop(6408);
            } else if (selection == 38) {
                cm.openShop(6409);
                cm.dispose();
            } else if (selection == 39) {
                cm.openShop(6500);
                cm.dispose();
            } else if (selection == 40) {
                cm.openShop(6501);
                cm.dispose();
            } else if (selection == 41) {
                cm.openShop(6502);
                cm.dispose();
            } else if (selection == 42) {
                cm.openShop(6503);
                cm.dispose();
            } else if (selection == 43) {
                cm.openShop(6504);
                cm.dispose();
            } else if (selection == 44) {
                cm.openShop(6505);
                cm.dispose();
            } else if (selection == 45) {
                cm.openShop(6600);
                cm.dispose();
            } else if (selection == 46) {
                cm.openShop(6601);
                cm.dispose();
            } else if (selection == 47) {
                cm.openShop(6700);
                cm.dispose();
            } else if (selection == 48) {
                cm.openShop(6800);
                cm.dispose();
            } else if (selection == 49) {
                cm.openShop(6801);
                cm.dispose();
            } else if (selection == 50) {
                cm.openShop(6900);
                cm.dispose();
            } else if (selection == 51) {
                cm.openShop(5000);
                cm.dispose();
            } else if (selection == 54) {
                cm.openShop(5004);
                cm.dispose();
            } else if (selection == 53) {
                cm.openShop(5002);
                cm.dispose();
            } else if (selection == 52) {
                cm.openShop(5003);
                cm.dispose();
                //  cm.openNpc(2120003);
            } else if (selection == 55) {
                cm.openShop(5005);
                cm.dispose();
            } else if (selection == 56) {
                cm.openShop(10055);
                cm.dispose();
            } else if (selection == 57) {
                cm.openShop(10056);
                cm.dispose();
            } else if (selection == 58) {
                cm.openShop(10057);
                cm.dispose();
            } else if (selection == 59) {
                cm.openShop(10058);
                cm.dispose();
            } else if (selection == 60) {
                cm.openShop(10059);
                cm.dispose();
            } else if (selection == 61) {
                cm.openShop(10060);
                cm.dispose();
            } else if (selection == 62) {
                cm.openShop(10061);
                cm.dispose();
            } else if (selection == 63) {
                cm.openShop(10062);
                cm.dispose();
            } else if (selection == 64) {
                cm.openShop(10063);
                cm.dispose();
            } else if (selection == 65) {
                cm.openShop(10064);
                cm.dispose();
            } else if (selection == 66) {
                cm.openShop(10065);
                cm.dispose();
            } else if (selection == 67) {
                cm.openShop(10066);
                cm.dispose();
            } else if (selection == 68) {
                cm.openShop(10067);
                cm.dispose();
            } else if (selection == 69) {
                cm.openShop(10068);
                cm.dispose();
            } else if (selection == 70) {
                cm.openShop(10069);
                cm.dispose();
            } else if (selection == 71) {
                cm.openShop(13035);
                cm.dispose();
            } else if (selection == 72) {
                cm.openShop(13001);
                cm.dispose();
            } else if (selection == 73) {
                cm.openShop(13002);
                cm.dispose();
            } else if (selection == 74) {
                cm.openShop(13003);
                cm.dispose();
            } else if (selection == 75) {
                cm.openShop(13004);
                cm.dispose();
            } else if (selection == 76) {
                cm.openShop(13005);
                cm.dispose();
            } else if (selection == 77) {
                cm.sendSimple("#e#d您目前有　(#r" + cm.getPlayer().getVotePoints() + "#d點) 貢獻點數. #b\r\n #L88換貢獻點數 #L94貢獻點數商店");
            }
        } else if (status == 3) {
            if (selection == 88) {
                cm.sendSimple("#e您目前有　(#r" + cm.getPlayer().getVotePoints() + "#k點) 貢獻點數." +
                        "#k\r\n#e您需要多少呢?" +
                        "#k\r\n#L89##r1萬#b NX點 換 1 貢獻點數" +
                        "#k\r\n#L90##r2萬#b NX點 換 2 貢獻點數" +
                        "#k\r\n#L91##r3萬#b NX點 換 3 貢獻點數" +
                        "#k\r\n#L92##r4萬#b NX點 換 4 貢獻點數" +
                        "#k\r\n#L93##r5萬#b NX點 換 5 貢獻點數");
            } else if (selection = 94) {
                cm.sendSimple("#e您目前有　(#r" + cm.getPlayer().getVotePoints() + "#k點) 貢獻點數." +
                        "#k\r\n#e您想要什麼方塊呢?" +
                        "#k\r\n#L95#1 貢獻點數換 #r1個傳說方塊" +
                        "#k\r\n#L96#2 貢獻點數換 #r2個傳說方塊" +
                        "#k\r\n#L97#3 貢獻點數換 #r3個傳說方塊" +
                        "#k\r\n#L98#4 貢獻點數換 #r4個傳說方塊" +
                        "#k\r\n#L99#5 貢獻點數換換 #r5個傳說方塊");
            }
        } else if (status == 4) {
            if (selection == 89) {
                if (cm.getPlayer().getCSPoints(1) > 10000) {
                    cm.gainNXCredit(-10000);
                    cm.getPlayer().gainVotePoints(1);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的NX點數不足!");
                    cm.dispose();
                }
            } else if (selection == 90) {
                if (cm.getPlayer().getCSPoints(1) > 20000) {
                    cm.gainNXCredit(-20000);
                    cm.getPlayer().gainVotePoints(2);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的NX點數不足!");
                    cm.dispose();
                }
            } else if (selection == 91) {
                if (cm.getPlayer().getCSPoints(1) > 30000) {
                    cm.gainNXCredit(-30000);
                    cm.getPlayer().gainVotePoints(3);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的NX點數不足!");
                    cm.dispose();
                }
            } else if (selection == 92) {
                if (cm.getPlayer().getCSPoints(1) > 40000) {
                    cm.gainNXCredit(-40000);
                    cm.getPlayer().gainVotePoints(4);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的NX點數不足!");
                    cm.dispose();
                }
            } else if (selection == 93) {
                if (cm.getPlayer().getCSPoints(1) > 50000) {
                    cm.gainNXCredit(-50000);
                    cm.getPlayer().gainVotePoints(5);
                    cm.dispose();  
                } else {
                    cm.sendOk("#e您目前的NX點數不足!");
                    cm.dispose();
                }
            } else if (selection == 95) {
                if (cm.getPlayer().getVotePoints() > 0) {
                    cm.getPlayer().gainVotePoints(-1);
                    cm.gainItem(5062002, 1);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的貢獻點數不足!");
                    cm.dispose();
                }
            } else if (selection == 96) {
                if (cm.getPlayer().getVotePoints() > 1) {
                    cm.getPlayer().gainVotePoints(-2);
                    cm.gainItem(5062002, 2);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的貢獻點數不足!");
                    cm.dispose();
                }
            } else if (selection == 97) {
                if (cm.getPlayer().getVotePoints() > 2) {
                    cm.getPlayer().gainVotePoints(-3);
                    cm.gainItem(5062002, 3);
                } else {
                    cm.sendOk("#e您目前的貢獻點數不足!");
                    cm.dispose();
                }
            } else if (selection == 98) {
                if (cm.getPlayer().getVotePoints() > 3) {
                    cm.getPlayer().gainVotePoints(-4);
                    cm.gainItem(5062002, 4);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的貢獻點數不足!");
                    cm.dispose();
                }
            } else if (selection == 99) {
                if (cm.getPlayer().getVotePoints() > 4) {
                    cm.getPlayer().gainVotePoints(-5);
                    cm.gainItem(5062002, 5);
                    cm.dispose();
                } else {
                    cm.sendOk("#e您目前的貢獻點數不足!");
                    cm.dispose();
                }
            }
        }
    }

}  